
import axios from 'axios';
/** checkLogin 返回一个Promise
 * 
 * new Promise(验证成功的回调函数， 验证失败或请求出错的回调函数 )
 * 
 */
let checkLogin = function () {
    return new Promise(function (resolve, reject) {
        let gazi_token = "";
        if (window.localStorage)
        {
            gazi_token = window.localStorage.gazi_token;
        }
        
        axios({
            method: 'get',
            url: '/login',
            params: {
                gazi_token: gazi_token
            }
            
        })
        .then( function (response) {
            let datas = response.data;
            //只有等于0说明 ok , 
           
            if (datas.data === 0)
            {
                resolve();
            }
            else
            {
                reject();
            }

            
        },function (err) {
            reject();
        })
    });
}

export default
{
    checkLogin: checkLogin
}